#include <vector>
#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    for (int tt = 0; tt < t; tt++)
    {
        int E, V;
        cin >> E >> V;
        V -= E;
        int N;
        cin >> N;
        vector<int> val(N);
        vector<int> w(N);
        for (int i = 0; i < N; i++)
            cin >> val[i] >> w[i];
        vector<int> dp(V + 1, 0x3f3f3f3f);
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
            for (int v = w[i]; v <= V; v++)
                dp[v] = min(dp[v], dp[v - w[i]] + val[i]);
        }
        if (dp[V] == 0x3f3f3f3f)
            cout << "This is impossible." << endl;
        else
            cout << "The minimum amount of money in the piggy-bank is " << dp[V] << "." << endl;
    }
    return 0;
}